<!DOCTYPE html>
<html lang="zh-cn">
<head>
	{include file="common/header" /}
	{include file="common/css" /}
	{include file="common/js" /}
</head>
<body>
    <div id="wrapper">
		{include file="common/dialog" /}
		{include file="common/navbar" /}
        <div id="page-wrapper">
			<div class="row" id="first_row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">修改密码</div>
                        <div class="panel-body">                            
							<form id="main_form" role="form">
								<div class="form-group">
									<table>
										<tr>
											<td class="title_column">
												<label>旧密码：</label>
											</td>
											<td>
												<input class="form-control" placeholder="请输入旧密码" type="password" id="old_pwd" name="old_pwd" />
											</td>
										</tr>
										<tr>
											<td class="title_column">
												<label>新密码：</label>
											</td>
											<td>
												<input class="form-control" placeholder="请输入新密码" type="password" id="pwd" name="pwd" />
											</td>
										</tr>
										<tr>
											<td class="title_column">
												<label>确认密码：</label>
											</td>
											<td>
												<input class="form-control" placeholder="请输入确认密码" type="password" id="pwd2" name="pwd2" />
											</td>
										</tr>
										<tr>
											<td colspan="2">
												<div class="btn_submit_div">
													<input type="submit" id="btn_submit" class="btn btn-outline btn-primary" value="修改" />
												</div>
											</td>
										</tr>
									</table>									
								</div>
							</form>							
                        </div>
                    </div>
                </div>             				
            </div>
            <script src="{$Think.config.web_res_root}mgr/js/user/updatepwd.js"></script>
<script>
$(function() {
	
	$("#main_form").validate({
		rules: {
			old_pwd: {
				required: true,
				minlength: 5
			},
			pwd: {
				required: true,
				minlength: 5,
				equalTo: "#pwd2"
			}
		},
		messages: {
			old_pwd: {
				required: "没有填写旧密码",
				minlength: $.validator.format("旧密码不能小于{0}个字符")
			},
			pwd: {
				required: "没有填写新密码",
				minlength: "新密码不能小于{0}个字符",
				equalTo: "两次输入密码不一致"
			}
		},
		submitHandler: function(form) {
							
			var data = {
				old_pwd: hex_md5($("#old_pwd").val()),
				pwd: hex_md5($("#pwd").val()),
				pwd2: hex_md5($("#pwd2").val())					
			};
			
			$.ajax({
				url: cfg.web_root + "mgr/user/updatepwd",
				type: "post",
				dataType: "json",
				data: data,
				beforeSend: function() {
					$("#btn_submit").attr("disabled", true);
				},
				success: function(res, status) {
					
					$("#dialog_alert").find(".modal-body").html(res.msg);
					$("#dialog_alert").modal("show");
				},
				complete: function() {
					$("#btn_submit").attr("disabled", false);
					$("#main_form").get(0).reset();
				}
			});
			
			return false;
		}
	});
	
});
</script>	
        </div>
        
    </div>
	
</body>
</html>
